/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.nuage.tiow.ui;

import com.vaadin.ui.Panel;
import com.vaadin.ui.Table;
import java.util.List;
import java.util.Map;
import org.nuage.tiow.vo.campaign.SystemState;
import org.nuage.tiow.vo.system.Planet;
import org.nuage.tiow.vo.system.SolarSystem;
import org.nuage.tiow.vo.user.Player;

/**
 *
 * @author quentina
 */
public class SolarSystemStatePanel extends Panel {

    public SolarSystemStatePanel(SolarSystem solarSystem, SystemState systemState) {
        setCaption("State of system " + solarSystem.getName());
        Map<Player, List<Planet>> playerControls = systemState.getPlayerControls();

        Table table = new Table();
        table.addContainerProperty("player", String.class, "");
        table.addContainerProperty("planet", String.class, "");
        for (Player player : playerControls.keySet()) {
            List<Planet> planets = playerControls.get(player);
            for (Planet planet : planets) {
                table.addItem(new Object[]{player.getName(), planet.getName()}, player.getName() + "_" + planet.getName());
            }
        }

        addComponent(table);
    }
}
